/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GUI.java
 *
 * Created on 12/07/2012, 10:20:51 AM
 */
/**
 *
 * @author CarlosAndre
 */
import java.awt.Component;
import javax.swing.JOptionPane;
import javax.swing.JFrame;
/** Descripción: clase GUI que es la intefaz grafica
     * Nombre: GUI
     * Parametros: 
     * Pre-condicion: 
     * Post-condicion: 
     */
public class GUI extends javax.swing.JFrame {
    private String numero,cadena_op;
    private float numero1,numero2;
    private boolean on,valor_inicial;
    Stack<Float> vector = new StackVector<Float>();
    
    /** Descripción: Constructor de la clase GUI
     * Nombre: GUI
     * Parametros: ninguno
     * Pre-condicion: 
     * Post-condicion: inicializa las variables
     */
    public GUI() {
        initComponents();
        JFrame frame;
        numero="0";
        on=false;
        jButton1.setEnabled(false);
        jButton2.setEnabled(false);
        jButton3.setEnabled(false);
        jButton4.setEnabled(false);
        jButton5.setEnabled(false);
        jButton6.setEnabled(false);
        jButton7.setEnabled(false);
        jButton8.setEnabled(false);
        jButton9.setEnabled(false);
        jButton10.setEnabled(false);
        jButton11.setEnabled(false);
        jButton12.setEnabled(false);
        jButton13.setEnabled(false);
        jButton14.setEnabled(false);
        jButton15.setEnabled(false);
        jButton16.setEnabled(false);
        jButton17.setEnabled(false);
        valor_inicial=true;
        numero="";
        cadena_op="";
        jLabel4.setText("");
        jFrame1.setTitle("Calculadora");
        
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDialog1 = new javax.swing.JDialog();
        jInternalFrame1 = new javax.swing.JInternalFrame();
        jPanel1 = new javax.swing.JPanel();
        jOptionPane1 = new javax.swing.JOptionPane();
        jFrame1 = new javax.swing.JFrame();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        jButton14 = new javax.swing.JButton();
        jButton15 = new javax.swing.JButton();
        jButton16 = new javax.swing.JButton();
        jToggleButton1 = new javax.swing.JToggleButton();
        jButton17 = new javax.swing.JButton();
        jButton18 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();

        javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
        jDialog1.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jDialog1Layout.setVerticalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        jInternalFrame1.setVisible(true);

        javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
        jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
        jInternalFrame1Layout.setHorizontalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jInternalFrame1Layout.setVerticalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
        jFrame1.getContentPane().setLayout(jFrame1Layout);
        jFrame1Layout.setHorizontalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jFrame1Layout.setVerticalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(450, 550));
        getContentPane().setLayout(null);

        jLabel1.setBackground(new java.awt.Color(255, 255, 255));
        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel1.setText("0");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(40, 40, 350, 44);

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        getContentPane().add(jLabel2);
        jLabel2.setBounds(47, 11, 0, 0);

        jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton1.setText("0");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1);
        jButton1.setBounds(130, 260, 80, 45);

        jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton2.setText("1");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton2);
        jButton2.setBounds(40, 210, 80, 45);

        jButton3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton3.setText("2");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton3);
        jButton3.setBounds(130, 210, 80, 45);

        jButton4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton4.setText("3");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton4);
        jButton4.setBounds(220, 210, 80, 45);

        jButton5.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton5.setText("4");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton5);
        jButton5.setBounds(40, 160, 80, 45);

        jButton6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton6.setText("5");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton6);
        jButton6.setBounds(130, 160, 80, 45);

        jButton7.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton7.setText("6");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton7);
        jButton7.setBounds(220, 160, 80, 45);

        jButton8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton8.setText("7");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton8);
        jButton8.setBounds(40, 110, 80, 45);

        jButton9.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton9.setText("8");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton9);
        jButton9.setBounds(130, 110, 80, 45);

        jButton10.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton10.setText("9");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton10);
        jButton10.setBounds(220, 110, 80, 45);

        jButton11.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton11.setText(".");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton11);
        jButton11.setBounds(40, 260, 80, 45);

        jButton12.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton12.setText("+");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton12);
        jButton12.setBounds(330, 110, 80, 45);

        jButton13.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton13.setText("-");
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton13);
        jButton13.setBounds(330, 160, 80, 45);

        jButton14.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton14.setText("*");
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton14);
        jButton14.setBounds(330, 210, 80, 45);

        jButton15.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton15.setText("c");
        jButton15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton15ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton15);
        jButton15.setBounds(330, 310, 80, 45);

        jButton16.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        jButton16.setText("Enter");
        jButton16.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton16ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton16);
        jButton16.setBounds(220, 260, 80, 92);

        jToggleButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jToggleButton1.setText("ON");
        jToggleButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jToggleButton1);
        jToggleButton1.setBounds(40, 370, 80, 40);

        jButton17.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton17.setText("/");
        jButton17.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton17ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton17);
        jButton17.setBounds(330, 260, 80, 45);

        jButton18.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton18.setText("Instrucciones");
        jButton18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton18ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton18);
        jButton18.setBounds(130, 440, 180, 25);

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 368, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );

        getContentPane().add(jPanel2);
        jPanel2.setBounds(30, 40, 370, 40);

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createCompoundBorder());

        jLabel4.setBackground(new java.awt.Color(255, 255, 255));
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel4.setText("jLabel4"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jLabel4)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        getContentPane().add(jPanel3);
        jPanel3.setBounds(30, 10, 370, 20);

        jPanel4.setBackground(new java.awt.Color(204, 102, 0));

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 280, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 260, Short.MAX_VALUE)
        );

        getContentPane().add(jPanel4);
        jPanel4.setBounds(30, 100, 280, 260);

        jPanel5.setBackground(new java.awt.Color(204, 102, 0));

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 260, Short.MAX_VALUE)
        );

        getContentPane().add(jPanel5);
        jPanel5.setBounds(320, 100, 100, 260);

        jPanel6.setBackground(new java.awt.Color(0, 0, 102));

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 430, Short.MAX_VALUE)
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 590, Short.MAX_VALUE)
        );

        getContentPane().add(jPanel6);
        jPanel6.setBounds(0, 0, 430, 590);

        pack();
    }// </editor-fold>//GEN-END:initComponents
    /** Descripción: si se presiona un numero
     * Nombre: jButton4ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: 
     * Post-condicion: imprime el numero ingresado
     */
    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        if (valor_inicial==true){
            numero="";
            valor_inicial=false;
        }
        numero+="3";
        jLabel1.setText(numero);
    }//GEN-LAST:event_jButton4ActionPerformed
    /** Descripción: si se presiona un numero
         * Nombre: jButton6ActionPerformed
         * Parametros: evt que es un evento (clic)
         * Pre-condicion: 
         * Post-condicion: imprime el numero ingresado
         */
    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
        if (valor_inicial==true){
            numero="";
            valor_inicial=false;
        }
        numero+="5";
        jLabel1.setText(numero);
    }//GEN-LAST:event_jButton6ActionPerformed
    /** Descripción: si se presiona un numero
     * Nombre: jButton16ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: 
     * Post-condicion: imprime el numero ingresado
     */
    private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton16ActionPerformed
        // TODO add your handling code here:
        jLabel1.setText("0");
        numero1=Float.valueOf(numero);
        vector.push(numero1);
        valor_inicial=true;
        cadena_op+=" ";
        cadena_op+=numero;
        jLabel4.setText(cadena_op);
        
    }//GEN-LAST:event_jButton16ActionPerformed
    /** Descripción: si se presiona un numero
     * Nombre: jButton1ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: 
     * Post-condicion: imprime el numero ingresado
     */
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        if (valor_inicial==true){
            numero="";
            valor_inicial=false;
        }
        numero+="0";
        jLabel1.setText(numero);
    }//GEN-LAST:event_jButton1ActionPerformed
    /** Descripción: si se presiona un numero
     * Nombre: jButton2ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: 
     * Post-condicion: imprime el numero ingresado
     */
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        if (valor_inicial==true){
            numero="";
            valor_inicial=false;
        }
        numero+="1";
        jLabel1.setText(numero);
    }//GEN-LAST:event_jButton2ActionPerformed
    /** Descripción: si se presiona un numero
     * Nombre: jButton3ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: 
     * Post-condicion: imprime el numero ingresado
     */
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        if (valor_inicial==true){
            numero="";
            valor_inicial=false;
        }
        numero+="2";
        jLabel1.setText(numero);
    }//GEN-LAST:event_jButton3ActionPerformed
    /** Descripción: si se presiona un numero
     * Nombre: jButton5ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: 
     * Post-condicion: imprime el numero ingresado
     */
    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
        if (valor_inicial==true){
            numero="";
            valor_inicial=false;
        }
        numero+="4";
        jLabel1.setText(numero);
    }//GEN-LAST:event_jButton5ActionPerformed
    /** Descripción: si se presiona un numero
     * Nombre: jButton7ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: 
     * Post-condicion: imprime el numero ingresado
     */
    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
        if (valor_inicial==true){
            numero="";
            valor_inicial=false;
        }
        numero+="6";
        jLabel1.setText(numero);
    }//GEN-LAST:event_jButton7ActionPerformed
    /** Descripción: si se presiona un numero
     * Nombre: jButton8ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: 
     * Post-condicion: imprime el numero ingresado
     */
    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here:
        if (valor_inicial==true){
            numero="";
            valor_inicial=false;
        }
        numero+="7";
        jLabel1.setText(numero);
    }//GEN-LAST:event_jButton8ActionPerformed
    /** Descripción: si se presiona un numero
     * Nombre: jButton9ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: 
     * Post-condicion: imprime el numero ingresado
     */
    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        // TODO add your handling code here:
        if (valor_inicial==true){
            numero="";
            valor_inicial=false;
        }
        numero+="8";
        jLabel1.setText(numero);
    }//GEN-LAST:event_jButton9ActionPerformed
    /** Descripción: si se presiona un numero
     * Nombre: jButton10ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: 
     * Post-condicion: imprime el numero ingresado
     */
    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        // TODO add your handling code here:
        if (valor_inicial==true){
            numero="";
            valor_inicial=false;
        }
        numero+="9";
        jLabel1.setText(numero);
    }//GEN-LAST:event_jButton10ActionPerformed
    /** Descripción: si se presiona un numero
     * Nombre: jButton11ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: 
     * Post-condicion: imprime el numero ingresado
     */
    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        // TODO add your handling code here:
        if (valor_inicial==true){
            numero="";
            valor_inicial=false;
        }
        numero+=".";
        jLabel1.setText(numero);
    }//GEN-LAST:event_jButton11ActionPerformed
    /** Descripción: si se presiona enciende o apaga la calculadora
     * Nombre: jToggleButton1ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: esta encendida o apagada
     * Post-condicion: enciende o apaga la calculadora
     */
    private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton1ActionPerformed
        // TODO add your handling code here:
        if (on==true){
            jButton1.setEnabled(false);
            jButton2.setEnabled(false);
            jButton3.setEnabled(false);
            jButton4.setEnabled(false);
            jButton5.setEnabled(false);
            jButton6.setEnabled(false);
            jButton7.setEnabled(false);
            jButton8.setEnabled(false);
            jButton9.setEnabled(false);
            jButton10.setEnabled(false);
            jButton11.setEnabled(false);
            jButton12.setEnabled(false);
            jButton13.setEnabled(false);
            jButton14.setEnabled(false);
            jButton15.setEnabled(false);
            jButton16.setEnabled(false);
            jButton17.setEnabled(false);
            while (vector.empty()==false){
                vector.pop();
            }
            if (vector.empty()==true){
                numero="0";
                jLabel1.setText(numero);
            }
            numero1=0;
            numero2=0;
            cadena_op="";
            jLabel4.setText(cadena_op);
            on=false;
        }
        else{
            jButton1.setEnabled(true);
            jButton2.setEnabled(true);
            jButton3.setEnabled(true);
            jButton4.setEnabled(true);
            jButton5.setEnabled(true);
            jButton6.setEnabled(true);
            jButton7.setEnabled(true);
            jButton8.setEnabled(true);
            jButton9.setEnabled(true);
            jButton10.setEnabled(true);
            jButton11.setEnabled(true);
            jButton12.setEnabled(true);
            jButton13.setEnabled(true);
            jButton14.setEnabled(true);
            jButton15.setEnabled(true);
            jButton16.setEnabled(true);
            jButton17.setEnabled(true);
            on=true;
        }
    }//GEN-LAST:event_jToggleButton1ActionPerformed
    /** Descripción: operacion de suma
     * Nombre: jButton12ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: debe haber algo en el Stack
     * Post-condicion: imprime el resultado
     */
    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        // TODO add your handling code here:
        if (vector.empty()==false){
           numero1=vector.peek();
           vector.pop();
           if (vector.empty()==false){
               numero2=vector.peek();
               vector.pop();
           }
           else{
               numero2=numero1;
               cadena_op+=String.valueOf(" "+numero2);
           }
        }
        numero1+=numero2;
        jLabel1.setText(String.valueOf(numero1));
        vector.push(numero1);
        cadena_op+=" + = ";
        cadena_op+=String.valueOf(numero1);
        jLabel4.setText(String.valueOf(cadena_op));
        
    }//GEN-LAST:event_jButton12ActionPerformed
    
    /** Descripción: operacion de resta
     * Nombre: jButton13ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: debe haber algo en el Stack
     * Post-condicion: imprime el resultado
     */
    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
        // TODO add your handling code here:
        if (vector.empty()==false){
           numero1=vector.peek();
           vector.pop();
           if (vector.empty()==false){
               numero2=vector.peek();
               vector.pop();
           }
           else{
               numero2=numero1;
               cadena_op+=String.valueOf(" "+numero2);
           }
        }
        numero1-=numero2;
        jLabel1.setText(String.valueOf(numero1));
        vector.push(numero1);
        cadena_op+=" - = ";
        cadena_op+=String.valueOf(numero1);
        jLabel4.setText(String.valueOf(cadena_op));
    }//GEN-LAST:event_jButton13ActionPerformed

    /** Descripción: operacion de multiplicacion
     * Nombre: jButton14ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: debe haber algo en el Stack
     * Post-condicion: imprime el resultado
     */
    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
        // TODO add your handling code here:
        if (vector.empty()==false){
           numero1=vector.peek();
           vector.pop();
           if (vector.empty()==false){
               numero2=vector.peek();
               vector.pop();
           }
           else{
               numero2=numero1;
               cadena_op+=String.valueOf(" "+numero2);
           }
        }
        numero1*=numero2;
        jLabel1.setText(String.valueOf(numero1));
        vector.push(numero1);
        cadena_op+=" * = ";
        cadena_op+=String.valueOf(numero1);
        jLabel4.setText(String.valueOf(cadena_op));
    }//GEN-LAST:event_jButton14ActionPerformed

    /** Descripción: vacia el Stack
     * Nombre: jButton15ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: debe haber algo en el Stack
     * Post-condicion: hace pop al Stack
     */
    private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton15ActionPerformed
        // TODO add your handling code here:
        cadena_op="";
        jLabel4.setText(cadena_op);
        numero="0";
        jLabel1.setText(numero);
        valor_inicial=true;
        while (vector.empty()==false){
            vector.pop();
        }
    }//GEN-LAST:event_jButton15ActionPerformed
    /** Descripción: operacion de division
     * Nombre: jButton17ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: debe haber algo en el Stack
     * Post-condicion: imprime el resultado
     */
    private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton17ActionPerformed
        // TODO add your handling code here:
        if (vector.empty()==false){
           numero1=vector.peek();
           vector.pop();
           if (vector.empty()==false){
               numero2=vector.peek();
               vector.pop();
           }
           else{
               numero2=numero1;
               cadena_op+=String.valueOf(" "+numero2);
           }
        }
        if (numero1!=0){
            numero1=numero2/numero1;
            jLabel1.setText(String.valueOf(numero1));
            vector.push(numero1);
            cadena_op+=" / = ";
            cadena_op+=String.valueOf(numero1);
            jLabel4.setText(String.valueOf(cadena_op));
        }
        else jLabel1.setText("Math Error");
        
    }//GEN-LAST:event_jButton17ActionPerformed
    /** Descripción: despliegue del menu
     * Nombre: jButton18ActionPerformed
     * Parametros: evt que es un evento (clic)
     * Pre-condicion: 
     * Post-condicion: desplega las instrucciones
     */
    private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton18ActionPerformed

        // TODO add your handling code here:
       JOptionPane.showMessageDialog(jFrame1, "Debe ingresar el valor, luego presionar enter para guardarlo."
               + "\npara operar presione la operacion. Si solo hay un operando \ny presiona una operacion"
               + " se realizara la operacion con \nel mismo operando. Ej. si solo ha presionado 5"
               + " y presiona * \nhara 5*5=25. Forma correcta de emplearla 5 enter 3 enter * \n"
               + " y saldrá el resultado de la operación 15");
       
       
        
      
    }//GEN-LAST:event_jButton18ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new GUI().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton17;
    private javax.swing.JButton jButton18;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JFrame jFrame1;
    private javax.swing.JInternalFrame jInternalFrame1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JOptionPane jOptionPane1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JToggleButton jToggleButton1;
    // End of variables declaration//GEN-END:variables
}
